package test 
{
	import com.greensock.TweenNano;
	import flash.display.Sprite;
	import lynch.display.Depth2DContainer;
	
	/**
	 * ...
	 * @author 小痛
	 */
	public class DepthTest extends Sprite 
	{
		
		public function DepthTest() 
		{
			super();
			Starling.current.stage.addChild(this);
			
			var scene:Depth2DContainer = new Depth2DContainer(Starling.context);
			var stage:Stage = Starling.current.stage;
			
			for (var i:int = 0; i < 2000; i++) 
			{
				var quad:Quad = new Quad(30, 30, 0xffffff * Math.random());
				quad.x = stage.stageWidth * Math.random();// i * 128;
				quad.y = stage.stageHeight * Math.random();// j * 128;
				quad.alpha = Math.random();
				randomRun(quad);
				scene.addChild(quad);
			}
			addChild(scene);
			//EnterFrameHandler.add(scene.flatten);
			//Starling.current.stage.addChild(scene);
		}
		
		private function randomRun(target:Quad):void
		{
			TweenNano.to(target, 1, { x:Math.random() * stage.stageWidth,
				y:stage.stageHeight * Math.random(),
				onComplete:randomRun, onCompleteParams:[target] } );
		}
		
	}

}